#ifndef PHYSICS
#define PHYSICS

#include "../core/define.h"
#include "../core/engine/reference.h"
#include "../core/math/matrix3.h"
#include "../core/math/matrix4.h"
#include "../mesh/geometry.h"

#include <Bullet/btBulletCollisionCommon.h>
#include <Bullet/btBulletDynamicsCommon.h>

namespace sleek
{
    namespace core { namespace engine { class engine; class interface; } }
    namespace node
    {
        namespace physics
        {
            enum body_type{ bt_unknow, bt_static, bt_dynamic, bt_kinematc, bt_count };
            enum body_geometry{ bg_unknow, bg_box, bg_circle, bg_polygone, bg_count };

            class Physics : public core::engine::reference
            {
                public:
                    Physics(core::engine::engine*);
                    virtual ~Physics();

                    void setUserData(void*);
                    void setType(body_type);
                    void setMass(core::f32);
                    void setDensity(core::f32);
                    void setFriction(core::f32);
                    void setRestitution(core::f32);
                    void setRotation(core::math::vector3df);
                    void setPosition(core::math::vector3df);
                    void setGeometry(mesh::MeshBuffer*);

                    mesh::MeshBuffer* getGeometry();
                    core::math::vector3df getPosition();
                    core::math::vector3df getRotation();
                    core::f32 getRestitution();
                    core::f32 getFriction();
                    core::f32 getDensity();
                    core::f32 getMass();
                    body_type getType();
                    void* getUserData();

                    btRigidBody* getPhysics();
                protected:
                    btRigidBody *body;
                    mesh::MeshBuffer *geom;
                    btDiscreteDynamicsWorld *world;

                    body_type btyp;
                    body_geometry bgeo;

                    core::math::vector3df pos, rot;
                    core::f32 friction, restitution, density;
                    core::engine::engine *smgr;
                    void *userdata;
                private:
                    friend class node;
                    friend class cursor;
                    friend class Sprite;
            };
        }
    }
}
#endif // PHYSICS
